<template>
  <fieldset>
    <legend>子组件</legend>
    <h1>{{ msg }}</h1>
    <h1>来自父组件的:{{ val }}</h1>
    <button @click="ck">点击发送给父组件</button>
    <button @click="se">点击发送给Bro</button>
  </fieldset>
</template>
<script>
export default {
  data() {
    return {
      msg: "牢饭很大，你忍一下",
    };
  },
  props: ["val"],
  methods: {
    ck() {
      this.$emit("look", "来自子组件:" + this.msg);
    },
    se() {
      this.$bus.$emit("toBro", "来自Child的问候：" + this.msg);
    },
  },
  mounted() {
    this.$bus.$on("getBro", (input) => {
      console.log(input);
      this.msg = input;
      this.$bus.$off("getBro");
    });
  },
};
</script>
